Skeletal Animations


The functions found in this section are only for use with sprites that have been imported from a skeletal animation file (like the JSON files that Spine exports) and can be used to get information about an animation asset in your game, as well as for setting certain properties within an animation. These functions can to be used along with the regular sprite functions and variables, permitting you to (for example) mix two skeleton animations using these special functions while setting the image scale using the normal sprite instance variables. For more information on the sprite instance variables see the section on Instance Variables.

NOTE: For further information on importing skeletal animation sprites made with Spine, please see the section Importing Non-Bitmap Sprites.

These functions can be used to get and change the skin that a skeleton sprite is using:

  1. skeleton_skin_get
  2. skeleton_skin_set
  3. skeleton_skin_list

The following set of functions are specific to the attachments that a skeleton animation sprite can use:

  1. skeleton_attachment_get
  2. skeleton_attachment_set
  3. skeleton_attachment_create
  4. skeleton_attachment_create_colour

These functions can be used to get the current state of the bone data and state for a skeleton animation, as well as to set the bone data and state:

  1. skeleton_bone_data_get
  2. skeleton_bone_data_set
  3. skeleton_bone_state_get
  4. skeleton_bone_state_set
  5. skeleton_bone_list

These functions can be used to get get the slot data for a sprite as well as manipulate its colour:

  1. skeleton_slot_list
  2. skeleton_slot_data
  3. skeleton_slot_data_instance
  4. skeleton_find_slot
  5. skeleton_slot_colour_set
  6. skeleton_slot_colour_get
  7. skeleton_slot_alpha_get

The following functions can be used to get various different sets of data about a skeleton animation sprite:

  1. skeleton_get_minmax
  2. skeleton_get_num_bounds
  3. skeleton_get_bounds


You can also use various draw routines designed specifically for these types of sprite (apart from the regular draw_sprite() functions). These functions give you more control over what is being drawn and permit you to change animation specific features, such as timing and skins:

  1. skeleton_collision_draw_set
  2. draw_skeleton
  3. draw_skeleton_collision
  4. draw_skeleton_time


Tint Black Support


This feature allows the dark areas of Spine sprite slots to be tinted differently to the light areas (this is a Spine IDE feature, see the Tint black section here more details). Currently, in order to make use of this feature in GameMaker Studio 2, you are required to use a custom shader when drawing a spine sprite that uses it. This shader contains a global uniform variable called "gm_SpineTintBlackColour" which the runner fills with the current tint-black colour, retrieved from the Spine data automatically. The shader required is shown below:

The Vertex Shader (this is the same as the default passthrough vertex shader)

attribute vec3 in_Position; // (x,y,z)
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}


The Fragment Shader:

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

uniform vec4 gm_SpineTintBlackColour; // This is the uniform containing the tint-black colour

void main()
{
vec4 tb = gm_SpineTintBlackColour;
vec4 texcol = texture2D( gm_BaseTexture, v_vTexcoord );
vec4 outcol;
outcol.rgb = v_vColour.rgb * texcol.rgb;
outcol.rgb += tb.rgb * ((tb.a * (texcol.a - 1.0)) + (1.0 - texcol.rgb)); // This line performs the tint-black blending logic
outcol.a = v_vColour.a * texcol.a;
gl_FragColor = outcol;
}


You would use this by first calling the shader, then drawing the sprite, then resetting the shader, something like this:

shader_set(shd_spine_tint_black);
draw_self();
shader_reset();